package com.ty.day2.home;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/23 16:55
 */
public class Task3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入一行字符：");
        String str = sc.nextLine();
        StringBuilder builder = new StringBuilder(str);
        StringBuilder sort = sort(builder);
        System.out.println(sort);
    }
    static StringBuilder sort(StringBuilder s){
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < s.length()-1-i; j++) {
                if (s.charAt(j)>s.charAt(j+1)){
                    char t=s.charAt(j),t1=s.charAt(j+1);
                    s.replace(j,j+1, String.valueOf(t1));
                    s.replace(j+1,j+2, String.valueOf(t));
                }
            }
        }
        return s;
    }
}
